/*
 * Powered By dico
 * Since 2017 - 2018
 */package com.seeyoui.kensite.bussiness.orderlang.userCart.service;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.seeyoui.kensite.common.base.service.BaseService;

import java.util.*;

import com.seeyoui.kensite.common.base.domain.EasyUIDataGrid;
import com.seeyoui.kensite.common.base.service.BaseService;
import com.seeyoui.kensite.common.exception.CRUDException;
import com.seeyoui.kensite.common.util.*;
import com.seeyoui.kensite.common.constants.StringConstant;
import com.seeyoui.kensite.bussiness.orderlang.userCart.domain.UserCart;
import com.seeyoui.kensite.bussiness.orderlang.userCart.domain.UserCartDTO;
import com.seeyoui.kensite.bussiness.orderlang.userCart.domain.UserCartVO;
import com.seeyoui.kensite.bussiness.orderlang.userCart.persistence.UserCartMapper;

/**
 * UserCart
 * @author dico
 * @version 2.0
 * @since 1.0
 * @date 2018-02-07
 */

@Service
public class UserCartService extends BaseService {
	
	@Autowired
	private UserCartMapper userCartMapper;

	/**
	 * 根据ID查询单条数据
	 * @param id
	 * @return
	 * @throws CRUDException
	 */
	public UserCart findOne(String id) throws CRUDException{
		return userCartMapper.findOne(id);
	}
	/**
	 * 查询当前用户购物车内所有商品
	 * @param id
	 * @return
	 * @throws CRUDException
	 */
	public List<UserCartVO> queryAllUserCart(String id)throws CRUDException{
		return userCartMapper.queryAllUserCart(id);
	}
	
	/**
	 * 根据价格id查询采购清单内商品
	 * @param priceIdList
	 * @return
	 */
	public List<UserCartDTO> findListByPriceIds(List<String> priceIdList){
		return userCartMapper.findListByPriceIds(priceIdList);
	}
	
	/**
	 * 查询数据集合
	 * @param userCart
	 * @return
	 * @throws CRUDException
	 */
	public List<UserCart> findList(UserCart userCart) throws CRUDException {
		return userCartMapper.findList(userCart);
	}
	
	/**
	 * 查询所有数据集合
	 * @param userCart
	 * @return
	 * @throws CRUDException
	 */
	public List<UserCart> findAll(UserCart userCart) throws CRUDException {
		return userCartMapper.findAll(userCart);
	}
	
	/**
	 * 查询数据总数
	 * @param userCart
	 * @return
	 * @throws CRUDException
	 */
	public int findTotal(UserCart userCart) throws CRUDException {
		return userCartMapper.findTotal(userCart);
	}
	
	/**
	 * 查询数据总数排除当前数据
	 * @param userCart
	 * @return
	 * @throws CRUDException
	 */
	public int findExTotal(UserCart userCart) throws CRUDException {
		return userCartMapper.findExTotal(userCart);
	}
	
	/**
	 * 数据新增
	 * @param userCart
	 * @throws CRUDException
	 */
	public void save(UserCart userCart) throws CRUDException{
		userCart.preInsert();
		userCartMapper.save(userCart);
	}
	
	/**
	 * 数据修改
	 * @param userCart
	 * @throws CRUDException
	 */
	public void update(UserCart userCart) throws CRUDException{
		userCart.preUpdate();
		userCartMapper.update(userCart);			
	}
	
	/**
	 * 数据删除
	 * @param listId
	 * @throws CRUDException
	 */
	public void delete(List<String> listId) throws CRUDException {
		userCartMapper.delete(listId);
	}
	
	/**
	 * 数据假删除
	 * @param userCart
	 * @throws CRUDException
	 */
	public void remove(UserCart userCart) throws CRUDException{
		userCart.preUpdate();
		userCartMapper.remove(userCart);			
	}
	
}